org 07c00h
	mov ax,cs
	mov ds,ax
	mov es,ax
	mov ss,ax
	;GDT
	xor eax,eax
	mov eax,2
	call read_disk
	mov bx,0500h
	int 13h
	;inode
	xor eax,eax
	mov dword eax,[0500h+8]
	call read_disk
	mov bx,01000h
	int 13h
	;inode
	xor eax,eax
	mov dword eax,[0500h+8]
	inc eax
	call read_disk
	mov bx,01400h
	int 13h
	;root
	xor eax,eax
	mov dword eax,[01000h+80h+40]
	call read_disk
	mov bx,0900h
	int 13h
	
	;find
	mov cx,20
	mov bx,0918h
re:
	mov al,[bx+8]
	cmp al,'r'
	jz loader
	mov ax,[bx+4]
	add bx,ax
	loop re
	;Loader.bin
loader:
	xor ecx,ecx
	xor edx,edx
	mov dword ecx,[bx]
	dec ecx
	mov eax,080h
	mul ecx
	mov ebx,eax
	xor eax,eax
	add ebx,01000h
	add ebx,40
	mov dword eax,[ebx]
	call read_disk
	mov bx,07e00h
	int 13h

	jmp 07e00h

read_disk:
	add eax,eax
	xor edx,edx
	mov ecx,18
	div ecx
	inc edx
	mov cl,dl
	mov edx,eax
	shr edx,1
	mov ch,dl
	and eax,1
	mov dh,al
	mov dl,0
	mov ah,02h
	mov al,2
	ret
times 510-($-$$) db 0
dw 0xaa55
